package com.zelic.znn.functions;

/**
 * @since 17/07/2011
 * @author zelic
 * FileName: BipolarSigmoidMethod.java
 * Description: bipolar form of sigmoid function 
 */

/**
 * BipolarSigmoidMethod is the output function which generate real value from -1 to 1
 * @author zelic
 */
public class BipolarSigmoidFunction implements OutputFunction{

    /**
     * Get Derivation at a specific number of bipolar sigmoid function
     * @param number : the point get derivation
     * @return derivation in double
     */
    @Override
    public double getDerivation(double number) {
        return (0.5*(1-number)*(1+number));
    }

    /**
     * Calculate output with bipolar sigmoid method
     * @param net:array of nets of units
     * @return output array 
     */
    @Override
    public double[] calculateOutputArray(double[] net) {
        int length = net.length;
        double[] result = new double[length];
        for (int i=0;i<length;i++){
            result[i] = (2.0/(1+Math.exp(-net[i]))-1.0);
        }
        return result;
    }
    
}
